package com.nantian.ecm.cebecm.concurrentframe;

import java.util.concurrent.ConcurrentLinkedQueue;

public class Task implements Runnable {

	private ConcurrentLinkedQueue<Object> taskQueue = new ConcurrentLinkedQueue<Object>();

	@Override
	public void run() {
		Object taskInfo = taskQueue.poll();
		while (taskInfo != null) {
			// 执行任务处理
			doTask(taskInfo);

			// 从任务列表中移除
			taskQueue.remove(taskInfo);
			// 取下一个任务
			taskInfo = taskQueue.poll();
		}
	}

	public ConcurrentLinkedQueue<Object> getTaskQueue() {
		return taskQueue;
	}

	public void setTaskQueue(ConcurrentLinkedQueue<Object> taskQueue) {
		this.taskQueue = taskQueue;
	}

	protected void doTask(Object o) {
		if (o instanceof String) {
			System.out.println("Thread : " + Thread.currentThread().getName()
					+ "   doTask:" + o);
		}
	}
}
